package br.com.yurikimo.ykkit;

import java.util.Hashtable;

import android.graphics.Typeface;

public class YKFontManager{
	public static final int FONT_TTF = 1;
	public static final int FONT_OTF = 2;
	
	private Hashtable<String, Typeface> fontHashTable = new Hashtable<String, Typeface>();
	private static YKFontManager instance;
	
	private static YKFontManager getInstance(){
		if (instance == null){
			instance = new YKFontManager();
		}
		
		return instance;
	}
	
	public static Typeface loadFont(String fontName, int fontType){
		String fontPathName = "fonts/" + fontName + ".ttf";
		
		if (fontType == FONT_OTF){
			fontPathName = "fonts/" + fontName + ".otf";
		}
		
		Typeface typeFace = getInstance().fontHashTable.get(fontName);
		
		if (typeFace == null){
			typeFace = Typeface.createFromAsset(YKDirector.getActivity().getAssets(), fontPathName);
			
			getInstance().fontHashTable.put(fontName, typeFace);
		}
		
		return typeFace;
	}
}
